home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2092 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.4 KB

  1. Path: server-b.cs.interbusiness.it!usenet
  2. From: Softec@system.abacom.it (Softec@system.abacom.it)
  3. Newsgroups: comp.lang.c++
  4. Subject: Help with Cedit view !
  5. Date: 15 Jan 1996 17:53:19 GMT
  6. Organization: Centro Servizi Interbusiness
  7. Message-ID: <4de4af$s71@server-b.cs.interbusiness.it>
  8. NNTP-Posting-Host: system.abacom.it
  9. Mime-Version: 1.0
  10. X-Newsreader: WinVN 0.99.2
  11.  
  12. I'm developing an editor using the Microsoft Visual C++ and the MFC.
  13. My editor has the following features:
  14.     1. Show the content of a ASCII file.
  15.     2. Change the text color and the background color of a line when a particular
  16. condition occours (same as when I set a breakpoint in the Visual C++ editor)
  17.  
  18. I tried to derivated the CEditView class and I loaded the file using the following code:
  19.  
  20.     CEdit& edit = GetEditCtrl();        // get a reference to the CEdit control
  21.     CFile f;                // used by the edit view
  22.  
  23.     if(!f.Open(filename, CFile::modeRead | CFile::typeBinary))
  24.         {
  25.         AfxMessageBox("File no found");
  26.         return 0;
  27.         }
  28.     DWORD len = f.GetLength();
  29.     HLOCAL hBuff = LocalAlloc(LMEM_MOVEABLE,len+1);
  30.     LPSTR = (LPSTR)LocalLock(hBuff);
  31.     f.Read(pbuff,len);
  32.     f.Close();
  33.     pbuff[len]=NULL;
  34.     edit.SetWindowText(pbuff);
  35.     edit.SetReadOnly(TRUE);        // Read only
  36.     LocalUnlock(hBuff);
  37.     LocalFree(hBuff);    
  38.     return 0;
  39.  
  40.  
  41. But now I don't know how to change the color of a line.
  42. Where is somebody that can help me ?
  43.  
  44. Thank you in advance
  45.     Piero Poletto
  46.  
  47.  
  48.